﻿using Demo.Filter;
using LightWadf.Processor;
using LightWadf.Result;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Demo.Processor
{
    public class BlogProcessor : AbstractProcessor
    {
        public override void InitRouteRule()
        {
            this.AddRouteRule("/", "Index");
            this.AddRouteRule("/hello/blog", "HelloBlog");
            this.AddRouteRule("/blog/post", "Post", ActionMethod.Post);
            this.AddRouteRule("/pre-{att:t[string],d[test2],l[1,20]}-suf", "TestMeaning");
        }

        public string Index(HttpContext context)
        {
            return "index";
        }

        public string TestMeaning(HttpContext context, Dictionary<string, object> param)
        {
            return (string)param["att"];
        }

        [TestFilter]
        public string HelloBlog(HttpContext context)
        {
            return "hello blog";
        }

        public JsonResult Post(HttpContext context)
        {
            return new JsonResult("json");
        }
    }
}